class MyCircularQueue {
    public int[] elem;
    public int usedSize;
    public int front;//队头下标
    public int rear;//对位下标
    public MyCircularQueue(int k) {
        this.elem = new int[k];
    }

    //1.入队
    public boolean enQueue(int value) {
        if (isFull()){
            return false;
        }

        this.elem[rear] = value;
        //rear++; 千万不能加加 因为7不能到0
        rear = (rear+1)% elem.length;
        this.usedSize++;
        return true;
    }

    //2.出队
    public boolean  deQueue() {
        if (isEmpty()){
            return false;
        }
        front = (front+1)% elem.length;
        this.usedSize--;
        return true;
    }

    //3. 获取队头元素
    public int Front() {
        if (isEmpty()){
            return -1;
        }
        return elem[front];
    }

    //4. 获取队尾元素
    public int Rear() {
        if (isEmpty()){
            return -1;
        }
        int index = (rear == 0) ? elem.length - 1: rear - 1;
        return elem[index];
    }

//    public boolean  isEmpty1() {
//        return rear == front;
//    }
//
//    public boolean  isFull1() {
//        return (rear+1)% elem.length == front;
//    }
    public boolean  isEmpty() {
        return usedSize == 0;
    }

    public boolean  isFull() {
        return usedSize == elem.length;
    }
};